var express = require('express')
var router = express.Router()

var svgCaptcha = require('svg-captcha')
let params = {
	width: 100,
	height: 32,
	noise: 2,
	size: 4,
	color: true,
	ignoreChars: '0o1il-',
	background: '#ccc'
}

// 增加
router.get('/captcha', function (req, res, next) {
	params.charPreset = req.query.text
	var svg = svgCaptcha.create(params)
	req.session.captcha = svg.text
	res.json({
		code: 0,
		data: svg.data,
		msg: 'success'
	})
})

module.exports = router
